package com.bigegg.employee.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.bigegg.employee.domain.BoardReview;
import com.bigegg.employee.service.IBoardReviewService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 公告预览Controller
 * 
 * @author sun
 * @date 2022-08-15
 */
@RestController
@RequestMapping("/board/review")
public class BoardReviewController extends BaseController
{
    @Autowired
    private IBoardReviewService boardReviewService;

    /**
     * 查询公告预览列表
     */
    @PreAuthorize("@ss.hasPermi('employee:review:list')")
    @GetMapping("/list")
    public TableDataInfo list(BoardReview boardReview)
    {
        startPage();
        List<BoardReview> list = boardReviewService.selectBoardReviewList(boardReview);
        return getDataTable(list);
    }

    /**
     * 导出公告预览列表
     */
    @PreAuthorize("@ss.hasPermi('employee:review:export')")
    @Log(title = "公告预览", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BoardReview boardReview)
    {
        List<BoardReview> list = boardReviewService.selectBoardReviewList(boardReview);
        ExcelUtil<BoardReview> util = new ExcelUtil<BoardReview>(BoardReview.class);
        util.exportExcel(response, list, "公告预览数据");
    }

    /**
     * 获取公告预览详细信息
     */
    @PreAuthorize("@ss.hasPermi('employee:review:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(boardReviewService.selectBoardReviewById(id));
    }

    /**
     * 新增公告预览
     */
    @PreAuthorize("@ss.hasPermi('employee:review:add')")
    @Log(title = "公告预览", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BoardReview boardReview)
    {
        return toAjax(boardReviewService.insertBoardReview(boardReview));
    }

    /**
     * 修改公告预览
     */
    @PreAuthorize("@ss.hasPermi('employee:review:edit')")
    @Log(title = "公告预览", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BoardReview boardReview)
    {
        return toAjax(boardReviewService.updateBoardReview(boardReview));
    }

    /**
     * 删除公告预览
     */
    @PreAuthorize("@ss.hasPermi('employee:review:remove')")
    @Log(title = "公告预览", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(boardReviewService.deleteBoardReviewByIds(ids));
    }
}
